#!/usr/bin/env python
# encoding=utf-8
import sys

from pymongo import MongoClient
from scpy.logger import get_logger

reload(sys)
sys.setdefaultencoding('utf-8')
logger = get_logger(__file__)
MONGO = MongoClient('127.0.0.1', 27017)


def find_all_industry():
    from collections import Counter
    c = Counter()
    for index, item in enumerate(MONGO['stockProj']['stockInfo'].find()):
        c[item['industry']] += 1
    import json
    print json.dumps(c, ensure_ascii=False, indent=4, sort_keys=True)
    print '\n'.join(c.keys())


if __name__ == '__main__':
    find_all_industry()
